<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!-- 引入vue开发环境版本 -->
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
</head>

<body>
    <div id="vm">
        姓：<input type="text" v-model="firstName"></br>
        名：<input type="text" v-model="lastName"></br>
        全名：<span>{{fullName}}</span> </br>
    </div>

    <script type="text/javascript">
        Vue.config.productionTip = false; //阻止vue在启动时产生生产环境提示

        var vm = new Vue({
            el: '#vm',
            data: {
                firstName: '张',
                lastName: '三'
            },
            computed: {
                //当只有考虑读取不考虑修改的时候采用简写的形式
                fullName() {
                    return this.firstName + '_' + this.lastName;
                }
            }
        })
    </script>
</body>
</html>